<template>
  <!--正在装载-->
  <div id="LoadingDetails">
    <g-details :detailData="inputData"
               :rules="rules"
               :inputConfig="inputConfig"
               ref="input"></g-details>
  </div>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "LoadingDetails",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object
    }
  },

  data () {
    return {
      inputConfig: [
          {
            type: "input",
            label: this.$t('in.vehiclenumber'),
            disabled: false,
            props: "vehiclenumber"
          },
          {
            type: "date",
            label: this.$t('in.vehicledate'),
            disabled: false,
            props: "vehicledate"
          },
          {
            type: "select",
            label: this.$t('in.termsnote'),
            disabled: false,
            props: "termsnote",
            options: this.getOptions("codelkup/PMTTERM")
          },
          {
            type: "select",
            label: this.$t('in.incoterms'),
            disabled: false,
            props: "incoterms",
            options: this.getOptions("codelkup/INCOTERMS")
          },
          {
            type: "input",
            label: this.$t('in.placeofloading'),
            disabled: false,
            props: "placeofloading"
          },
          {
            type: "input",
            label: this.$t('in.placeofdischarge'),
            disabled: false,
            props: "placeofdischarge"
          },
          {
            type: "input",
            label: this.$t('in.placeofdelivery'),
            disabled: false,
            props: "placeofdelivery"
          },
          {
            type: "select",
            label: this.$t('config.transportationmode'),
            disabled: false,
            props: "transportationmode",
            options: this.getOptions("codelkup/TRANSPMODE")
          },
          {
            type: "select",
            label: this.$t('in.destinationcountry'),
            disabled: false,
            props: "destinationcountry",
            options: this.getOptions("codelkup/ISOCOUNTRY")
          },
          {
            type: "select",
            label: this.$t('in.origincountry'),
            disabled: false,
            props: "origincountry",
            options: this.getOptions("codelkup/ISOCOUNTRY")
          },
          {
            type: "textarea",
            label: this.$t('common.note'),
            disabled: false,
            props: "notes"
          },
          {
            type: "select",
            label: this.$t('common.type'),
            disabled: false,
            props: "containertype",
            options: this.getOptions("codelkup/CONTAINERT")
          },
          {
            type: "input",
            label: this.$t('config.num'),
            disabled: false,
            props: "containerqty"
          }
      ],
      rules: {
        containerqty: [
          { validator: this.containerqty, trigger: 'blur' },
        ]
      },
    };
  },
  methods: {
    containerqty (rule, value, callback) {
      if (value === '') {
        callback();
      } else {
        var re = /^[0-9]*$/;
        let te = value;
        let flag = re.test(te)
        if (flag) {
          if (value < 0) {
            this.$message.error(this.$t('app.inputGreaterZeroNumberPlease'))
            this.inputData[rule.field] = ""
            callback(new Error());
          } else {
            callback();
          }
        } else {
          this.$message.error(this.$t('app.inputGreaterZeroNumberPlease'))
          this.inputData[rule.field] = ""
          callback(new Error());
        }
      }
    },
  },
  mounted () {
    if (!this.inputData.hasOwnProperty('containerqty')) {
      this.$set(this.inputData, "containerqty", null)
    }
  },
};
</script>

<style scoped>
</style>

